package reflect;

import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args)throws Exception {
        Class cls=Class.forName("reflect.Person");
        Object obj=cls.newInstance();


        Method method= cls.getMethod("doSameThing", String.class);
        method.invoke(obj,"玩游戏");
        method= cls.getMethod("doSameThing", String.class, int.class);
        method.invoke(obj,"王五",23);

    }
}
